//
//  DecoratingCell.m
//  NewNest
//
//  Created by hesiyao on 16/1/19.
//  Copyright © 2016年 www.lanou3g.com蓝鸥科技. All rights reserved.
//

#import "DecoratingCell.h"
#import <UIColor+Wonderful.h>
@implementation DecoratingCell

-(void)dealloc
{
    [_backImg release];
    [_titleLabel release];
    [_spaceLabel release];
    [_contentLabel release];
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        //背景图片
        self.backImg = [[UIImageView alloc] init];
        [self.contentView addSubview:_backImg];
        [_backImg release];
        
        //标题
        self.titleLabel = [[UILabel alloc] init];
        [self.contentView addSubview:_titleLabel];
        _titleLabel.textAlignment = NSTextAlignmentCenter;
        _titleLabel.font = [UIFont systemFontOfSize:15];
        [_titleLabel release];
        
        // 面积
        self.spaceLabel = [[UILabel alloc] init];
        [self.contentView addSubview:_spaceLabel];
        _spaceLabel.font = [UIFont systemFontOfSize:12];
        _spaceLabel.textColor = [UIColor seaShell];
        _spaceLabel.textAlignment = NSTextAlignmentRight;
        [_spaceLabel release];
        
        // 内容
        self.contentLabel = [[UILabel alloc] init];
        [self.contentView addSubview:_contentLabel];
        _contentLabel.font = [UIFont systemFontOfSize:12];
        _contentLabel.textColor = [UIColor seaShell];
        [_contentLabel release];
        
    }
    return self;
}

-(void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes
{
    [super applyLayoutAttributes:layoutAttributes];
    
    self.backImg.frame = CGRectMake(0, 0, self.contentView.frame.size.width, self.contentView.frame.size.height / 6 * 5);
    
    self.titleLabel.frame = CGRectMake(0, self.contentView.frame.size.height / 6 * 5, self.contentView.frame.size.width, self.contentView.frame.size.height / 6);
    self.contentLabel.frame = CGRectMake(_titleLabel.frame.origin.x, self.contentView.frame.size.height / 3 * 2, self.contentView.frame.size.width / 3 * 2, self.contentView.frame.size.height / 6);
    self.spaceLabel.frame = CGRectMake(self.contentView.frame.size.width / 3 * 2, _contentLabel.frame.origin.y, self.contentView.frame.size.width / 3, _contentLabel.frame.size.height);
}

@end
